﻿using System;
using System.Collections.Generic;
using System.Text;
using Antu.WebControls;
using System.Web.UI.WebControls;
using EluZSProvider;
using Antu.Core.Services;
using System.Web;
using System.Data;

namespace WebSys.UI.OfficeFlow
{
    public class FwbuchangQiangzhiControl : MPBasicTemplate
    {
        EluZSDataProvider _EluZSDataProvider = (EluZSDataProvider)ProviderService.ProviderServiceMange.GetProvider("EluZSProvider");
        MPPersistence Persistence1; Panel panel1;
        TextBox 区划, 被征收人, 性别, 民族, 地址,
字, 第, 号, 区, 区划1,
字1, 第1, 号1, 被征收人1, 门牌号,
区划2, 字2, 第2, 号2, 区1,
区2;

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            InitControl();
            panel1 = (Panel)FindControl("panel1");
            Persistence1 = (MPPersistence)FindControl("Persistence1");
            if (!base.Page.IsPostBack)
            {

                Persistence1.Table = "zs_强制执行申请书";//数据库中对应的表
                Persistence1.Key = "IID";//表的主键列名称
                Persistence1.KeyValue = HttpContext.Current.Request.QueryString["IID"];//主键列的值
                Persistence1.ConnStr = _EluZSDataProvider.GetConnectionString();//数据库连接字符串
            }
            Persistence1.BindControl = panel1;//持久化控件的控制对象为Panel中的所以的字段，panel1是Panel的ID

            Button Button1 = (Button)FindControl("Button1");
            if (string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["IID"]))
            {
                Button1.Visible = false;

            }
            else
            {
                Button1.Click += new EventHandler(Button1_Click);
            }
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            Persistence1.Update();
            base.Page.Response.Redirect("FwbuchangQiangzhi.aspx?IID=" + base.Page.Request["IID"]);
        }
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);
            
            TextBox txtIID = (TextBox)FindControl("txtIID");
            txtIID.Text = HttpContext.Current.Request.QueryString["IID"];
            string strIID = HttpContext.Current.Request.QueryString["IID"];
            if (!string.IsNullOrEmpty(strIID))
            {
                string sql = "select * from zs_征收补偿决定书 where iid='" + strIID + "' ";
                DataTable dt = _EluZSDataProvider.GetOneDs("(" + sql + ")", "*", "").Tables[0];
                区划.Text = dt.Rows[0]["区"].ToString();
                被征收人.Text = dt.Rows[0]["被征收人"].ToString();
                性别.Text = dt.Rows[0]["性别"].ToString();
                民族.Text = dt.Rows[0]["民族"].ToString();
                地址.Text = dt.Rows[0]["地址"].ToString();
                字.Text = dt.Rows[0]["字"].ToString();
                第.Text = dt.Rows[0]["第"].ToString();
                号.Text = dt.Rows[0]["号"].ToString();
                区.Text = dt.Rows[0]["区"].ToString();
                区划1.Text = dt.Rows[0]["区"].ToString();
                字1.Text = dt.Rows[0]["字"].ToString();
                第1.Text = dt.Rows[0]["第"].ToString();
                号1.Text = dt.Rows[0]["号"].ToString();
                被征收人1.Text = dt.Rows[0]["被征收人"].ToString();
                门牌号.Text = dt.Rows[0]["门牌号"].ToString();
                区划2.Text = dt.Rows[0]["区"].ToString();
                字2.Text = dt.Rows[0]["字"].ToString();
                第2.Text = dt.Rows[0]["第"].ToString();
                号2.Text = dt.Rows[0]["号"].ToString();
                区1.Text = dt.Rows[0]["区"].ToString();
                区2.Text = dt.Rows[0]["区"].ToString();
            }
        }
        protected void InitControl()
        {
            区划 = (TextBox)FindControl("区划");
            被征收人 = (TextBox)FindControl("被征收人");
            性别 = (TextBox)FindControl("性别");
            民族 = (TextBox)FindControl("民族");
            地址 = (TextBox)FindControl("地址");
            字 = (TextBox)FindControl("字");
            第 = (TextBox)FindControl("第");
            号 = (TextBox)FindControl("号");
            区 = (TextBox)FindControl("区");
            区划1 = (TextBox)FindControl("区划1");
            字1 = (TextBox)FindControl("字1");
            第1 = (TextBox)FindControl("第1");
            号1 = (TextBox)FindControl("号1");
            被征收人1 = (TextBox)FindControl("被征收人1");
            门牌号 = (TextBox)FindControl("门牌号");
            区划2 = (TextBox)FindControl("区划2");
            字2 = (TextBox)FindControl("字2");
            第2 = (TextBox)FindControl("第2");
            号2 = (TextBox)FindControl("号2");
            区1 = (TextBox)FindControl("区1");
            区2 = (TextBox)FindControl("区2");

        }
    }
}
